#ifndef PTRACCESSOPSIMULATOR_H_
#define PTRACCESSOPSIMULATOR_H_

#include "graph_support/GraphSupport.h"

namespace GRAPH_SUPPORT_NS
{
namespace utils
{

template< typename T >
class PtrAccessOpSimulator
{
private:
	typedef PtrAccessOpSimulator< T > MyT;

public:
	PtrAccessOpSimulator( const T & content )
		: content( content )
	{
	}

	PtrAccessOpSimulator( T * content )
		: content( * content )
	{
	}

	PtrAccessOpSimulator()
	{
	}

	PtrAccessOpSimulator( int ) // GrEdgePtr eptr = NULL;
	{
	}

	T * operator -> ()
	{
		return & content;
	}

	const T * operator -> () const
	{
		return & content;
	}

	T & operator * ()
	{
		return content;
	}

	T & operator * () const
	{
		MyT * self = const_cast< MyT * >( this );
		return self->content;
	}

	bool operator == ( const PtrAccessOpSimulator< T > & that ) const
	{
		return this->content == that.content;
	}

	bool operator != ( const PtrAccessOpSimulator< T > & that ) const
	{
		return ! ( ( * this ) == that );
	}

private:
	T content;
};

// TODO: separate such operator utils
template < typename ObjT, typename PtrT >
ObjT & ptr2ref( const PtrT & ptr )
{
	return * ptr;
}

template < typename T, typename A >
T & shlOperator( T & t, const A & arg )
{
	t << arg;
	return t;
}

template < typename T >
const T & incrOperator( T & t )
{
	++t;
	return t;
}

template < typename ElemT, typename CollT, typename PositionT >
ElemT & accessOperator( CollT & coll, const PositionT & position )
{
	return coll[position];
}

}
}

#endif /* PTRACCESSOPSIMULATOR_H_ */
